OLE Insert Rich Text

I'm not very good with this OLE stuff.  Can I paste rich text directly into an MS-Word cell?

I've got a OleAutoObj handle on the 'Range' of the 'Cell', but when I 'InsertAfter' I get the rich text tags instead of the rich text.  'InsertAfter' for raw text is working.

  • string Text = richTextWithOle(oCurr."Object Text")
    clear(oaaArgs)
    put(oaaArgs, "Text", Text)
    oleMethod(oaoRange, "InsertAfter", oaaArgs)

Table cell looks like:

  • {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Tahoma ...

Do I have to copy-paste via the clipboard?  Extract functions from "word.dxl"?  That looks like this (which is working), but I don't want to use the clipboard:

  • setRichClip(richText(Text))
    oleMethod(oaoRange, "Paste")

-Louie


llandale - Sat May 11 16:41:56 EDT 2013

Re: OLE Insert Rich Text
Adamarla - Mon May 13 01:11:08 EDT 2013

Unfortunatly, Word only auto converts richtext from either the clipboard or from an .rtf file. So your options for automation are copy/paste which hogs the clipboard, or writing  thousands of small files which thrashes the disk.

Re: OLE Insert Rich Text
llandale - Mon May 13 14:22:10 EDT 2013

Adamarla - Mon May 13 01:11:08 EDT 2013

Unfortunatly, Word only auto converts richtext from either the clipboard or from an .rtf file. So your options for automation are copy/paste which hogs the clipboard, or writing  thousands of small files which thrashes the disk.

Then is the following reasonable:

  • create an RTF file (using a Stream) with the contents I want
    •  Some header indicating the start/end of the table and how many columns there are supposed to be
    • the content of cells are separated by some special string of characters
  • With OLE, invoke a new Word instance and command it to open the RTF
  • Set 'Selection' using the special 'table' characters to select the entire table
  • Convert to Table, specifying the number of columns and using the special string of characters as the delimiters

This I think will require me to resolve the VBA issue of DefaultTableSeparator; which appears to be a string not a char.

-Louie